<?php
namespace Admin\Controller;
use Think\Controller;
class WishManageController extends CommonController {
    public function index(){ //显示的愿望管理页   这个显示是需要判断用户是否登录
        //查询所有愿望
        $sname=I('get.sname',"");
        $sop=I('get.sop',1);
        
        $wish=M("notes");
        $p=I('get.p',1);
        if ($sop==1)
        {
            
           $wishda=$wish->where("name like '%$sname%'")->page($p.',5')->select();
            $count=$wish->where("name like '%$sname%'")->count();
        }
        else{
            
            $wishda=$wish->where("content like '%$sname%'")->page($p.',5')->select();
             $count=$wish->where("content like '%$sname%'")->count();
            
        }
       
        $PAGE=new\Think\Page($count,5);
        $PAGE->lastSuffix = FALSE;
        $PAGE->setConfig('header','共 %TOTAL_ROW% 条记录,当前是第%NOW_PAGE%页, 共 %TOTAL_PAGE% 页<br/>');
        $PAGE->setConfig('first', '首页');
        $PAGE->setConfig('last', '尾页');
        $PAGE->setConfig('prev', '上一页');
        $PAGE->setConfig('next', '下一页');
        $PAGE->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
        $show=$PAGE->show();
        $this->assign("page",$show);
        $this->assign("sname",$sname);
        $this->assign("sop",$sop);
        $this->assign("wish",$wishda);
        $this->display();
    }  
     public function del()
     {
        $id=I('get.id',0);
	//实例化模型类
	$model=M('notes'); 	     
	$rs=$model->delete($id);
	if ($rs)
	   { //设置成功后跳转页面的地址，
          $this->success('删除成功', U('Admin/WishManage/index'));  
	   }
	   else
	   { //错误页面的默认跳转页面是返回前一页，通常不需要设置
         $this->error('删除失败');
	   }  
     }
}